import request from '@/api/request'
import { useUserStore } from '@/stores/user'

export default {
	//code to session_key and open_id
	async code_to_token() {
		let { code } = await uni.login({})
		let member = await request({
			url: '/wechat/login',
			data: { js_code: code }
		})
		// let {token} = await this.get_token({open_id: data.open_id})
		uni.setStorageSync('member',member)
		useUserStore().setUser(member)
	},
	
	//获取用户手机号
	getPhone: data => {
		return request({
			data,
			url: '/wechat/getPhoneNumber'
		})
	},

	//获取会员信息
	getMemberInfo: data => {
		return request({
			data,
			url: '/member/info'
		})
	},

	//我的收藏
	myCollect: data => {
		return request({
			data,
			url: '/member/collect'
		})
	},

	//我的员工
	employee: data => {
		return request({
			data,
			url: '/member/employeeList'
		})
	},

	//购买会员
	wxpay: data => {
		return request({
			data,
			url: '/member/buyVip'
		})
	},

	//购买条数
	wxpay2: data => {
		return request({
			data,
			url: '/member/packageTopup'
		})
	},

	//我的账户
	myAccount: data => {
		return request({
			data,
			url: '/member/myAccount'
		})
	},

	//我的账户明细
	myAccountDetail: data => {
		return request({
			data,
			url: '/member/myAccountDetail'
		})
	},

	//收藏
	collect: data => {
		return request({
			data,
			url: '/member/toCollect'
		})
	},

}
